package com.github.baichuan.mapping;

import java.time.Duration;

public class DurationConverter implements MappingConvertor {
    @Override
    public Object convert(Object value) {
        Duration duration = (Duration) value;
        if (duration.toDays() > 0){
            return duration.toDays() + "天";
        }
        if (duration.toHours() > 0){
            return duration.toHours() + "小时";
        }
        if (duration.toMinutes() > 0){
            return duration.toMinutes() + "分钟";
        }
        return duration.toMillis() / 1000 + "秒";
    }
}
